home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Cursor;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.image.MemoryImageSource;
- import java.awt.image.PixelGrabber;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
-
- public class ImageExtend extends Applet implements Runnable, MouseListener {
- boolean loaded;
- Thread thread;
- Image image;
- Image buffer;
- // $FF: renamed from: b java.awt.Graphics
- Graphics field_0;
- Color backColor;
- // $FF: renamed from: wi int
- int field_1;
- // $FF: renamed from: he int
- int field_2;
- int wiIm;
- int heIm;
- int pause = 20;
- static int[] pix;
- static int[] pixnew;
- // $FF: renamed from: f6 float
- float field_3 = 0.0F;
- // $FF: renamed from: f7 float
- float field_4 = 1.0F;
- // $FF: renamed from: f8 float
- float field_5 = 0.0F;
- // $FF: renamed from: f9 float
- float field_6 = 1.0F;
- float f6Step = 0.05F;
- float f7Step = -0.1F;
- float f8Step = 0.05F;
- float f9Step = -0.1F;
- private String statusBarText;
- private AudioClip sound;
- private AudioClip clicSound;
- private AudioClip enterSound;
- private boolean loopSound;
- private String link;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_7;
- private String enterText;
- private boolean isEnterTextEnabled;
- private int wiEnterText;
- private int enterTextHeight;
- private Color enterTextColor;
- private int decx;
- private int decy;
-
- public String getAppletInfo() {
- return "Name: ImageExtend\r\nAuthor: Taiji Software\r\n";
- }
-
- public ImageExtend() {
- this.f6Step = 0.05F;
- this.f7Step = -0.1F;
- this.f8Step = 0.05F;
- this.f9Step = -0.1F;
- this.backColor = Color.black;
- ((Component)this).addMouseListener(this);
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- this.stop();
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var11) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- this.image = ((Applet)this).getImage(((Applet)this).getCodeBase(), ((Applet)this).getParameter("image_name"));
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.image, 0);
-
- try {
- tracker.waitForAll();
- tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- if (!this.loaded) {
- this.stop();
- }
-
- this.wiIm = this.image.getWidth(this);
- this.heIm = this.image.getHeight(this);
- pix = new int[this.wiIm * this.heIm];
- pixnew = new int[this.wiIm * this.heIm];
- this.decx = (this.field_1 - this.wiIm) / 2;
- this.decy = (this.field_2 - this.heIm) / 2;
- PixelGrabber pixg = new PixelGrabber(this.image, 0, 0, this.wiIm, this.heIm, pix, 0, this.wiIm);
-
- try {
- pixg.grabPixels();
- } catch (InterruptedException var9) {
- }
-
- this.image = ((Component)this).createImage(new MemoryImageSource(this.wiIm, this.heIm, pixnew, 0, this.wiIm));
- this.buffer = ((Component)this).createImage(this.field_1, this.field_2);
- this.field_0 = this.buffer.getGraphics();
- this.field_0.setColor(this.enterTextColor);
- String fontName = ((Applet)this).getParameter("enter_text_font");
- if (fontName == null) {
- fontName = "TimesRoman";
- }
-
- int style = 1;
- String s = ((Applet)this).getParameter("enter_text_style");
- if (s != null) {
- if (s.equals("bold")) {
- style = 1;
- } else if (s.equals("italic")) {
- style = 2;
- } else if (s.equals("bold_italic")) {
- style = 3;
- } else {
- style = 0;
- }
- }
-
- this.field_0.setFont(new Font(fontName, style, this.enterTextHeight));
- this.field_7 = this.field_0.getFontMetrics();
- if (this.enterText != null) {
- this.wiEnterText = this.field_7.stringWidth(this.enterText);
- }
-
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- return;
- }
-
- this.sound.play();
- }
-
- }
-
- public void getParameters() {
- this.field_1 = ((Component)this).getSize().width;
- this.field_2 = ((Component)this).getSize().height;
- String s = ((Applet)this).getParameter("pause");
- if (s != null) {
- this.pause = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("topLeftCorner");
- if (s != null) {
- this.field_3 = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("topRightCorner");
- if (s != null) {
- this.field_4 = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("bottomRightCorner");
- if (s != null) {
- this.field_5 = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("bottomLeftCorner");
- if (s != null) {
- this.field_6 = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("topLeftStep");
- if (s != null) {
- this.f6Step = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("topRightStep");
- if (s != null) {
- this.f7Step = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("bottomRightStep");
- if (s != null) {
- this.f8Step = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- s = ((Applet)this).getParameter("bottomLeftStep");
- if (s != null) {
- this.f9Step = (float)((double)((float)Integer.parseInt(s)) / (double)100.0F);
- }
-
- this.backColor = this.getColor("background_color");
- ((Component)this).setBackground(this.backColor);
- this.statusBarText = ((Applet)this).getParameter("status_bar_text");
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- } else {
- this.loopSound = false;
- }
- }
-
- s = ((Applet)this).getParameter("clic_sound_name");
- if (s != null) {
- this.clicSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("enter_sound_name");
- if (s != null) {
- this.enterSound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- this.link = ((Applet)this).getParameter("link");
- this.enterText = ((Applet)this).getParameter("enter_text");
- s = ((Applet)this).getParameter("enter_text_height");
- if (s != null) {
- this.enterTextHeight = Integer.parseInt(s);
- }
-
- this.enterTextColor = this.getColor("enter_text_color");
- if (this.enterTextColor == null) {
- this.enterTextColor = Color.white;
- }
-
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void start() {
- if (this.thread == null) {
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.thread = null;
- }
-
- if (this.sound != null) {
- this.sound.stop();
- }
-
- }
-
- public void run() {
- Thread.currentThread().setPriority(4);
-
- while(true) {
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var1) {
- }
-
- this.calculatePixels();
- this.field_3 += this.f6Step;
- if (this.field_3 > 1.0F || this.field_3 < 0.0F) {
- this.f6Step = -this.f6Step;
- }
-
- this.field_4 += this.f7Step;
- if (this.field_4 > 1.0F || this.field_4 < 0.0F) {
- this.f7Step = -this.f7Step;
- }
-
- this.field_5 += this.f8Step;
- if (this.field_5 > 1.0F || this.field_5 < 0.0F) {
- this.f8Step = -this.f8Step;
- }
-
- this.field_6 += this.f9Step;
- if (this.field_6 > 1.0F || this.field_6 < 0.0F) {
- this.f9Step = -this.f9Step;
- }
- }
- }
-
- public final void paint(Graphics g) {
- if (!this.loaded) {
- this.field_0.setColor(Color.white);
- this.field_0.drawString("loading... please wait", 1, this.field_2 / 2);
- this.loaded = true;
- } else {
- if (this.image != null) {
- this.field_0.clearRect(0, 0, this.field_1, this.field_2);
- this.field_0.drawImage(this.image, this.decx, this.decy, this);
- if (this.isEnterTextEnabled) {
- this.field_0.drawString(this.enterText, (this.field_1 - this.wiEnterText) / 2, this.field_2 / 2);
- }
-
- this.image = null;
- }
-
- g.drawImage(this.buffer, 0, 0, this);
- }
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- private final void calculatePixels() {
- int w2 = this.wiIm / 2;
- int h2 = this.heIm / 2;
-
- for(int ii = 0; ii < this.heIm; ++ii) {
- for(int jj = 0; jj < this.wiIm; ++jj) {
- float r1 = this.field_3 + (float)jj * (this.field_4 - this.field_3) / (float)this.wiIm;
- float r2 = this.field_6 + (float)ii * (this.field_5 - this.field_6) / (float)this.heIm;
- float r3 = (float)(jj - h2) / r2 + (float)h2;
- float r4 = (float)(ii - w2) / r1 + (float)w2;
- if (r3 > 0.0F && r3 < (float)(this.wiIm - 1) && r4 > 0.0F && r4 < (float)(this.heIm - 1)) {
- float r5 = r3 - (float)((int)r3);
- float r6 = r4 - (float)((int)r4);
- int i = (int)((1.0F - r5) * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3, 16711680, 16) + (1.0F - r5) * r6 * (float)this.pixel((int)r4 + 1, (int)r3, 16711680, 16) + r5 * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3 + 1, 16711680, 16) + r5 * r6 * (float)this.pixel((int)r4 + 1, (int)r3 + 1, 16711680, 16));
- int j = (int)((1.0F - r5) * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3, 65280, 8) + (1.0F - r5) * r6 * (float)this.pixel((int)r4 + 1, (int)r3, 65280, 8) + r5 * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3 + 1, 65280, 8) + r5 * r6 * (float)this.pixel((int)r4 + 1, (int)r3 + 1, 65280, 8));
- int k = (int)((1.0F - r5) * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3, 255, 0) + (1.0F - r5) * r6 * (float)this.pixel((int)r4 + 1, (int)r3, 255, 0) + r5 * (1.0F - r6) * (float)this.pixel((int)r4, (int)r3 + 1, 255, 0) + r5 * r6 * (float)this.pixel((int)r4 + 1, (int)r3 + 1, 255, 0));
- pixnew[ii * this.wiIm + jj] = (new Color(i, j, k)).getRGB();
- } else {
- pixnew[ii * this.wiIm + jj] = this.backColor.getRGB();
- }
- }
- }
-
- this.image = ((Component)this).createImage(new MemoryImageSource(this.wiIm, this.heIm, pixnew, 0, this.wiIm));
- }
-
- public final int pixel(int i, int j, int hex, int dec) {
- return (pix[i * this.wiIm + j] & hex) >> dec;
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.clicSound != null) {
- this.clicSound.play();
- }
-
- if (this.link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(this.link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- if (this.isEnterTextEnabled) {
- this.isEnterTextEnabled = false;
- ((Component)this).repaint();
- }
-
- if (this.link != null) {
- ((Component)this).setCursor(new Cursor(0));
- }
-
- }
-
- public void mousePressed(MouseEvent e) {
- if (this.clicSound != null) {
- this.clicSound.play();
- }
-
- if (this.link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(this.link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-